<?php

namespace api\libs\notifications\models;

use Yii;

/**
 * This is the model class for table "notification_queue".
 *
 * @property integer $id
 * @property integer $type
 * @property integer $status
 * @property integer $content
 * @property integer $recipient_uid
 * @property string $recipient_contact
 * @property string $ctime
 * @property string $mtime
 * @property integer $send_time
 * @property integer $try
 */
class NotificationQueue extends \yii\db\ActiveRecord
{
     /**
     * email notification
     */
    const TYPE_EMAIL = 2;

    /**
     * sms notification
     */
    const TYPE_SMS = 3;
    
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'notification_queue';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['type', 'recipient_uid', 'recipient_contact'], 'required'],
            [['type', 'status', 'recipient_uid', 'send_time', 'try'], 'integer'],
            [['ctime', 'mtime'], 'safe'],
            [['recipient_contact'], 'string', 'max' => 128],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '消息队列ID',
            'type' => '消息类型 1-EMAIL 2-SMS',
            'status' => '状态，标识是否进行分发，0为已发 1为未发 2发送失败',
            'content' => '消息内容',
            'recipient_uid' => '收件人uid',
            'recipient_contact' => '联系方式',
            'ctime' => '创建时间',
            'mtime' => '实际发送时间',
            'send_time' => '需要发送的时间',
            'try' => '尝试次数',
        ];
    }
}
